//
//  ViewController.m
//  Test
//
//  Created by 郭洪军 on 8/4/17.
//  Copyright © 2017 Guo Hongjun. All rights reserved.
//

#import "ViewController.h"
#import "CoffeeShop.h"
#import "ELAnswerController.h"
#import "AlbumListController.h"

@interface ViewController ()

@property (nonatomic, strong) CoffeeShop *coffeeShop;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    
//    // 创建咖啡厅
//    self.coffeeShop = [[CoffeeShop alloc] init];
//    
//    // 相同类型的数据公用
//    [self.coffeeShop takeOrder:@"Cappuccino" table:1];
//    [self.coffeeShop takeOrder:@"Frappe"     table:10];
//    [self.coffeeShop takeOrder:@"Cappuccino" table:6];
//    [self.coffeeShop takeOrder:@"Espresso"   table:9];
//    [self.coffeeShop takeOrder:@"Frappe"     table:8];
//    
//    // 开始服务
//    [self.coffeeShop serve];
    
//    CGRect frame = CGRectMake(0, 0, 160, 160);
//
//    UIImageView *iv = [[UIImageView alloc] initWithFrame:frame];
//
////    iv.image =[UIImage imageNamed:@"avatar_default_big"] ;
//    iv.image = [self avatarIamge:[UIImage imageNamed:@"avatar_default_big"] size:frame.size] ;
//
//    [self.view addSubview:iv];
//
//    iv.center = self.view.center;
    
    UIButton *b = [[UIButton alloc] initWithFrame:CGRectMake(100, 100, 100, 40)];
    [self.view addSubview:b];
    [b setTitleColor:[UIColor blueColor] forState:UIControlStateNormal];
    [b setTitle:@"问答" forState:UIControlStateNormal];
    
    [b addTarget:self action:@selector(goAction:) forControlEvents:UIControlEventTouchUpInside];
    
    UIButton *b1 = [[UIButton alloc] initWithFrame:CGRectMake(100, 250, 100, 40)];
    [self.view addSubview:b1];
    [b1 setTitleColor:[UIColor blueColor] forState:UIControlStateNormal];
    [b1 setTitle:@"相册" forState:UIControlStateNormal];
    
    [b1 addTarget:self action:@selector(albumAction:) forControlEvents:UIControlEventTouchUpInside];
    
}

- (void)albumAction:(id)sender {
    AlbumListController *alVC = [[AlbumListController alloc] init];
    UINavigationController *naviController = [[UINavigationController alloc] initWithRootViewController:alVC];
    
    [self presentViewController:naviController animated:YES completion:nil];
}

- (void)goAction:(id)sender {
    ELAnswerController *answerController = [[ELAnswerController alloc] init];
    UINavigationController *naviController = [[UINavigationController alloc] initWithRootViewController:answerController];
    
    [self presentViewController:naviController animated:YES completion:nil];
}

- (UIImage *)avatarIamge:(UIImage *)image size:(CGSize)size {
    
    CGRect frame = CGRectMake(0, 0, size.width, size.height);
    
    UIGraphicsBeginImageContextWithOptions(frame.size, YES, 0);
    
    [image drawInRect:frame];
    
    UIImage *ret = UIGraphicsGetImageFromCurrentImageContext();
    
    UIGraphicsEndImageContext();
    
    return ret;
    
}



@end
